package edu.oregonstate.vision;

import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.File;
import java.io.FileReader;
import java.io.FileWriter;
import java.io.IOException;
import java.util.Vector;

public class SingleVectorDescriptorGenerator {
	public static void main(String[] args) {
		try {
			BufferedWriter bufferedWriter = new BufferedWriter(new FileWriter(
					new File("track_result.txt")));
			File[] files = new File("track_desc").listFiles();
			for (File file : files) {
				if (file.getName().contains("angleDS"))
					continue;
				File distanceAngle = new File("track_desc" + File.separator
						+ file.getName().split("_")[0] + "_" + "angleDS.txt");
				Vector<Float> feature = new Vector<Float>();
				BufferedReader bufferedReader;
				String line;
				bufferedReader = new BufferedReader(new FileReader(file));
				line = bufferedReader.readLine();
				while (line != null) {
					String[] strings = line.split(",");
					for (String string : strings) {
						feature.add(Float.valueOf(string));
					}
					line = bufferedReader.readLine();
				}

				bufferedReader = new BufferedReader(new FileReader(
						distanceAngle));
				line = bufferedReader.readLine();
				while (line != null) {
					String[] strings = line.split(",");
					for (String string : strings) {
						feature.add(Float.valueOf(string));
					}
					line = bufferedReader.readLine();
				}

				System.out.println(feature.size());
				for (int i = 0; i < feature.size(); i++) {
					if (i == 0) {
						bufferedWriter.write("" + feature.get(i));
					} else {
						bufferedWriter.write("," + feature.get(i));
					}
				}
				bufferedWriter.write('\n');
			}
			bufferedWriter.close();
		} catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}

	}
}
